package JavaSE.d2;

import java.util.Scanner;

public class Test11 {
    public static void main(String[] args) {
        System.out.println("请输入两个数字，获取之间的和");
        Scanner scanner = new Scanner(System.in);
        int star=scanner.nextInt();
        int end=scanner.nextInt();
        if(star<=end){
            System.out.println(getBetweenNumber(star,end));
        }else {
            System.out.println("前一个数字必须小于后一个！");
        }
    }


    private static int getBetweenNumber(int startNumber,int endNumber){
        int sum=startNumber;
        for (int i = startNumber+1; i <endNumber+1 ; i++) {
            sum=sum+i;

        }
        return sum;
    }
}
